<template>
  <div id="center">
    <div class="up">
      <div
        class="bg-color-black item"
        v-for="item in titleItem"
        :key="item.title"
      >
        <p class="ml-3 colorBlue fw-b fs-xl">{{ item.title }}</p>
        <div>
          <dv-digital-flop
            class="dv-dig-flop ml-1 mt-2 pl-3"
            :config="item.number"
          />
        </div>
      </div>
    </div>
    <div class="down">
      <div class="ranking bg-color-black">
        <div id="bar" :style="size">
          <div class="dragRectTop"></div>
          <e-charts :size="size" :options="options" />
          <div class="dragRectBottom"></div>
        </div>
      </div>
      <div class="ranking bg-color-black">
        <div id="bar" :style="size">
          <div class="dragRectTop"></div>
          <e-charts :size="size" :options="options2" />
          <div class="dragRectBottom"></div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
// import CenterChart from '@/components/echart/center/centerChartRate'
import ECharts from "@/views/ECharts";

export default {
  components: {
    ECharts,
    // CenterChart
  },
  data() {
    return {
      titleItem: [
        {
          title: 'MSE(成锭率)',
          number: {
            number: [0.00165],
            toFixed: 5,
            textAlign: 'left',
            content: '{nt}',
            style: {
              fontSize: 26
            }
          }
        },
        {
          title: 'MAE(成锭率)',
          number: {
            number: [0.03164],
            toFixed: 5,
            textAlign: 'left',
            content: '{nt}',
            style: {
              fontSize: 26
            }
          }
        },
        {
          title: 'R2(成锭率)',
          number: {
            number: [0.28277],
            toFixed: 5,
            textAlign: 'left',
            content: '{nt}',
            style: {
              fontSize: 26
            }
          }
        },
        {
          title: 'MSE(成材率)',
          number: {
            number: [0.00165],
            toFixed: 5,
            textAlign: 'left',
            content: '{nt}',
            style: {
              fontSize: 26
            }
          }
        },
        {
          title: 'MAE(成材率)',
          number: {
            number: [0.03128],
            toFixed: 5,
            textAlign: 'left',
            content: '{nt}',
            style: {
              fontSize: 26
            }
          }
        },
        {
          title: 'R2(成材率)',
          number: {
            number: [0.06128],
            toFixed: 5,
            textAlign: 'left',
            content: '{nt}',
            style: {
              fontSize: 26
            }
          }
        }
      ],
      water: {
        data: [24, 45],
        shape: 'roundRect',
        formatter: '{value}%',
        waveNum: 3
      },


      options: {
        title: {
          text: '',
          textStyle: {
            color: "rgba(255,255,255,0.9)"
          },
          left: "center",
          top: "5px"
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow'
          }
        },
        grid: {
          top: '20%',
          left: '10%',
          right: '10%',
          bottom: '4%',
          containLabel: true
        },
        xAxis: [
          {
            type: 'category',
            data: ['0.7','0.75', '0.8', '0.85','0.9','0.95'],
            axisTick: {
              alignWithLabel: true
            },
            axisLabel: {
              textStyle: {
                color: "rgba(255,255,255,0.6)",
                fontSize: "12"
              }
            }
          }
        ],
        yAxis: [
          {
            type: 'value',
            axisLabel: {
              textStyle: {
                color: "rgba(255,255,255,0.6)",
                fontSize: "12"
              }
            },
            axisLine: {
              lineStyle: {
                color: "rgba(255,255,255,0.3)"
              }
            },
            splitLine: {
              lineStyle: {
                color: "rgba(255,255,255,0.3)"
              }
            }
          }
        ],
        series: [
          {
            name: '数量',
            type: 'bar',
            barWidth: '35%',
            data: [],
            itemStyle: {
              barBorderRadius: 5
            }
          }
        ]
      },

      options2: {
        title: {
          text: '',
          textStyle: {
            color: "rgba(255,255,255,0.9)"
          },
          left: "center",
          top: "5px"
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow'
          }
        },
        grid: {
          top: '20%',
          left: '10%',
          right: '10%',
          bottom: '4%',
          containLabel: true
        },
        xAxis: [
          {
            type: 'category',
            data: ['0.7','0.75', '0.8', '0.85','0.9','0.95'],
            axisTick: {
              alignWithLabel: true
            },
            axisLabel: {
              textStyle: {
                color: "rgba(255,255,255,0.6)",
                fontSize: "12"
              }
            }
          }
        ],
        yAxis: [
          {
            type: 'value',
            axisLabel: {
              textStyle: {
                color: "rgba(255,255,255,0.6)",
                fontSize: "12"
              }
            },
            axisLine: {
              lineStyle: {
                color: "rgba(255,255,255,0.3)"
              }
            },
            splitLine: {
              lineStyle: {
                color: "rgba(255,255,255,0.3)"
              }
            }
          }
        ],
        series: [
          {
            name: '数量',
            type: 'line',
            barWidth: '35%',
            data: [],
            itemStyle: {
              barBorderRadius: 5,
              normal: {
                color: "#0f97f8"
              }
            }
          }
        ]
      },


      size: {
        width: '100%',
        height: '14.75rem'
      },
    }
  },
  mounted () {
    let i=0
    setInterval(() => {

        if(i==1){
          this.options.title.text='成锭率测试数据集分布'
          this.options.series[0].data=[0,2,0,7,15,15];
          this.options = { ...this.options };
          i=0;
        }else {
          this.options.title.text='成材率测试数据集分布'
          this.options.series[0].data=[0,3,4,20,12,1];
          this.options = { ...this.options };
          i++;
        }

      // this.year++;
      // this.options.title.text = `${this.year}年各行业市场占有金额`
      // this.options.series[0].data.forEach((item, i) => {
      //   this.options.series[0].data[i] = item + Math.floor(Math.random() * 100) - 50
      // })

    }, 1200)

    let j=0
    setInterval(() => {

      if(j==1){
        this.options2.title.text='成锭率训练数据集分布'
        this.options2.series[0].data=[0,6,1,23,66,60];
        this.options2 = { ...this.options2 };
        j=0;
      }else {
        this.options2.title.text='成材率训练数据集分布'
        this.options2.series[0].data=[1,15,11,85,41,7];
        this.options2 = { ...this.options2 };
        j++;
      }
    }, 1200)
  }

}
</script>

<style lang="scss" scoped>
#center {
  display: flex;
  flex-direction: column;
  .up {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    .item {
      border-radius: 6px;
      padding-top: 8px;
      margin-top: 8px;
      width: 32%;
      height: 70px;
      .dv-dig-flop {
        width: 150px;
        height: 30px;
      }
    }
  }
  .down {
    padding: 6px 4px;
    padding-bottom: 0;
    width: 100%;
    display: flex;
    height: 255px;
    justify-content: space-between;
    .bg-color-black {
      border-radius: 5px;
    }
    .ranking {
      padding: 10px;
      width: 49%;
      .dv-scr-rank-board {
        height: 225px;
      }
    }
    .percent {
      width: 50%;
      display: flex;
      flex-wrap: wrap;
      .item {
        width: 50%;
        height: 120px;
        span {
          margin-top: 8px;
          font-size: 14px;
          display: flex;
          justify-content: center;
        }
      }
      .water {
        width: 100%;
        .dv-wa-le-po {
          height: 120px;
        }
      }
    }
  }
}



#bar{
  /* background-image: url(../assets/line.png); */
  border: 0.5px solid rgba(255,255,255,0.2);
  position: relative;
  background: none;
}

.dragRectTop{
  width: 100%;
  height: 100px;
  position: absolute;
  top: 0;
  left: 0
}

.dragRectTop::before{
  content: "";
  width: 10px;
  height: 10px;
  border-left: 2px solid skyblue;
  border-top: 2px solid skyblue;
  display: block;
  position: absolute;
  left: 0;
  top: 0;
}

.dragRectTop::after{
  content: "";
  width: 10px;
  height: 10px;
  border-right: 2px solid skyblue;
  border-top: 2px solid skyblue;
  display: block;
  position: absolute;
  right: 0;
  top: 0;
}

.dragRectBottom{
  width: 100%;
  height: 10px;
  position: absolute;
  bottom: 0;
  left: 0
}

.dragRectBottom::before{
  content: "";
  width: 10px;
  height: 10px;
  border-left: 2px solid skyblue;
  border-bottom: 2px solid skyblue;
  display: block;
  position: absolute;
  left: 0;
  bottom: 0;
}

.dragRectBottom::after{
  content: "";
  width: 10px;
  height: 10px;
  border-right: 2px solid skyblue;
  border-bottom: 2px solid skyblue;
  display: block;
  position: absolute;
  right: 0;
  bottom: 0;
}
</style>
